{% extends "BackendBundle::backend.html.twig" %}

{% set vars = {'ruta' : app.request.attributes.get('_route')} %}

{% block title %}{{ "Articulos"|trans }}{% endblock %}

{% block header %}

    {% include "BackendBundle::topmenu.html.twig" with vars %}

{% endblock %}

{% block left %}

    {% include "ContentBundle:Hotel:menuleft.html.twig" with vars %}

{% endblock %}

{% block content %}

    <div class="span9">
    
        <h2>{{ "Articulos"|trans }}</h2>
        <fieldset>
            <legend>{{ "Articulos de"|trans }} "{{hotel.hotelname}}"</legend>
            
            {% if app.session.hasFlash('success') %}
            
                <div class="flash-notice alert alert-success">
                    <h4 class="alert-heading">{{ "Ok"|trans }}!</h4>                     
                    {{ app.session.flash('success') }}
                </div>
            
            {% endif %}

            {% if app.session.hasFlash('error') %}
            
                <div class="flash-notice alert alert-error">
                    <h4 class="alert-heading">{{ "Error"|trans }}!</h4>                        
                    {{ app.session.flash('error') }}
                </div>
            
            {% endif %}

            {% if app.session.hasFlash('info') %}
            
                <div class="flash-notice alert alert-info">
                    <h4 class="alert-heading">{{ "Info"|trans }}!</h4>
                    <p>{{ app.session.flash('info') }}</p>
                </div>
            
            {% endif %}
            
            {% if languages|length != 0 and articles|length != 0 %}
            
                <div class="btn-toolbar">
                    <div class="btn-group">

                        {% for language in languages %}

                            <a href="{{ path("ContentBundle_articles_list_idioma", {'ididioma': language.id}) }}" class="btn{% if idioma == language.id %} btn-primary{% endif %}">{{ language.idioma }}</a>

                        {% endfor %}    

                    </div>
                </div>
            
            {% endif %}
            
            <div class="well">
                
                {% if articles|length != 0 %}
                
                    <table class="table">
                        <thead>
                            <tr>
                                <th width="50%">{{ "Titulo"|trans }}</th>
                                <th>{{ "Seccion"|trans }}</th>
                                <th>{{ "Publicado"|trans }}</th>
                                <th width="20%"></th>
                            </tr>
                        </thead>
                        {% for article in articles %}
                        
                            {% if article.notraduccio == 1 %}
                        
                            <tbody>
                                <tr>
                                    <td style="vertical-align: middle;">{{article.titulo}}</td>
                                    <td colspan="2" style="vertical-align: middle;"><span class="label label-important">{{ "No hay traducción"|trans }}</span></td>
                                    <td style="vertical-align: middle;">
                                        <a href="{{ path("ContentBundle_article_tradu", {'ididioma': idioma, 'idarticle': article.idtradu}) }}" class="btn btn-warning" title="{{ "Crear Traducción"|trans }}"><i class="icon-globe icon-white">&nbsp;</i></a>
                                    </td>
                                </tr>
                            </tbody>                        
                        
                            {% else %}

                            <tbody>
                                <tr>
                                    <td style="vertical-align: middle;">{{article.titulo}}</td>
                                    <td style="vertical-align: middle;">
                                        {% for seccion in seccions %}                

                                            {% if seccion.idseccion == article.idseccion %}
                                                {{ seccion.nomseccion }}
                                            {% endif %}

                                        {% endfor %}
                                    </td>
                                    <td style="vertical-align: middle;">

                                        {% if article.published == 1 %}

                                            {% image '@ContentBundle/Resources/public/images/publicat.png' %}
                                                <img src="{{ asset_url }}" />
                                            {% endimage %}

                                        {% else %}

                                            {% image '@ContentBundle/Resources/public/images/no-publicat.png' %}
                                                <img src="{{ asset_url }}" />
                                            {% endimage %}

                                        {% endif %}

                                    </td>
                                    <td>
                                        <a href="{{ path("ContentBundle_article_edita", {'ididioma': article.ididioma, 'idarticle': article.id}) }}" class="btn" title="{{ "Editar"|trans }}"><i class="icon-pencil">&nbsp;</i></a> 
                                        <a href="{{ path("ContentBundle_article_borrar", {'ididioma': article.ididioma, 'idarticle': article.id}) }}" class="btn btn-danger" title="{{ "Borrar"|trans }}"><i class="icon-trash icon-white">&nbsp;</i></a>
                                    </td>
                                </tr>
                            </tbody>
                            
                            {% endif %}

                        {% endfor %}

                    </table>
                
                {% else %}

                    No hay articulos
                
                {% endif %}   
                
            </div>
            
        </fieldset>
    </div>

{% endblock %}
